<template>
  <a-config-provider :locale="antLocale">
    <router-view></router-view>
  </a-config-provider>
</template>

<script lang='ts'>
import { useI18n } from 'vue-i18n';
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import enUs from 'ant-design-vue/es/locale/en_US';
import { defineComponent, computed } from 'vue';
import { useStore } from './store/store';
import moment from 'moment';
import 'moment/dist/locale/zh-cn';
export default defineComponent({
  setup() {
    const { locale } = useI18n();
    const store = useStore();
    const antLocaleMap: any = {
      'zh-cn': zhCN,
      'en-us': enUs
    };
    const antLocale = computed(() => {
      const appLocale = store.state.app.locale;
      moment.locale(appLocale);
      locale.value = appLocale;
      window.localStorage.setItem('locale', appLocale);
      return antLocaleMap[appLocale];
    });
    return {
      antLocale
    };
  },
});
</script>